home *** CD-ROM | disk | FTP | other *** search
/ ShareWare OnLine 2 / ShareWare OnLine Volume 2 (CMS Software)(1993).iso / word / wp2latex.zip / WP2LATEX.C < prev    next >
C/C++ Source or Header  |  1990-11-18  |  55KB  |  2,456 lines

  1. /* Output from p2c, the Pascal-to-C translator */
  2. /* From input file "WP2LATEX.PAS" */
  3.  
  4. static char rcsid[] = "$Header: wp2latex.c,v 2.3 90/09/05 09:23:12 glenn Exp $";
  5.  
  6.  
  7. #ifdef HAVE_P2C
  8. #include <p2c/p2c.h>
  9. #else
  10. #include "p2c.h"
  11. #endif
  12.  
  13.  
  14. /*           Version 1.0
  15.              Date 27-1-1990
  16. */
  17.  
  18.  
  19. Static Char wpd_fn[256], strip_fn[256], tabel_fn[256], latex_fn[256];
  20.  
  21. Static FILE *wpd, *tabel;
  22. Static FILE *strip, *latex;
  23.  
  24. Static unsigned short num_of_lines_stripfile;
  25.  
  26. Static Char open_com[0x11][256], close_com[0x11][256];
  27.  
  28. /* Static Anyptr Exitsave; */
  29. Static Char wpd_NAME[_FNSIZE];
  30. Static Char tabel_NAME[_FNSIZE];
  31. Static Char strip_NAME[_FNSIZE];
  32. Static Char latex_NAME[_FNSIZE];
  33.  
  34. Static Void RunError(); /* simulate Turbo 5 builtin */
  35.  
  36. Static Void Rd_word(f, w)
  37. FILE **f;
  38. unsigned short *w;
  39. {
  40.   /* Deze procedure leest een woord uit de opgegeven binaire file. */
  41.   uchar b;
  42.  
  43.   fread(&b, sizeof(uchar), 1, *f);
  44.   *w = b;
  45.   fread(&b, sizeof(uchar), 1, *f);
  46.   *w += b * 256;
  47. }
  48.  
  49.  
  50. Static Void Wr_word(f, w)
  51. FILE **f;
  52. unsigned short w;
  53. {
  54.   /* Deze procedure schrijft een woord in de opgegeven binaire file. */
  55.   uchar b;
  56.  
  57.   b = w & 255;
  58.   fwrite(&b, sizeof(uchar), 1, *f);
  59.   b = w / 256;
  60.   fwrite(&b, sizeof(uchar), 1, *f);
  61. }
  62.  
  63.  
  64. Static Void Jump_in_file(f, dis)
  65. FILE **f;
  66. long dis;
  67. {
  68.   /* Deze procedure springt in een binaire file het aantal opgegeven bytes. */
  69.   long cur_pos;
  70.  
  71.   cur_pos = ftell(*f) / sizeof(uchar);
  72.   fseek(*f, (cur_pos + dis) * sizeof(uchar), 0);
  73. }
  74.  
  75.  
  76.  
  77. Static Void Wpd_check()
  78. {
  79.   /* Kontroleert of de opgegeven WP-document wel daadwerkelijk een   */
  80.   /* WP5.0-document is.                                              */
  81.   unsigned short id1, id2, std1, std2, filetype, dmp1, dmp2, dmp3;
  82.   long Startdoc;
  83.  
  84.   Rd_word(&wpd, &id1);
  85.   Rd_word(&wpd, &id2);
  86.   Rd_word(&wpd, &std1);
  87.   Rd_word(&wpd, &std2);
  88.   Rd_word(&wpd, &filetype);
  89.   Rd_word(&wpd, &dmp1);
  90.   Rd_word(&wpd, &dmp2);
  91.   Rd_word(&wpd, &dmp3);
  92.  
  93.   Startdoc = std2 * 65536L + std1;
  94.  
  95.   if (id1 == 0x57ff && id2 == 0x4350 && filetype == 0xa01)
  96.     /*and (dmp1=$0) and (dmp2=$0) and (dmp3=$0)*/
  97.       fseek(wpd, Startdoc * sizeof(uchar), 0);
  98.   else {
  99.     RunError(0x201);   /* Het is geen WP5.0-document*/
  100.   }
  101.  
  102.   /* Het is een WP5.0-document*/
  103. }
  104.  
  105.  
  106.  
  107.  
  108. Static Void Filenames()
  109. {
  110.   /* Deze procedure handelt het opgeven van de filenamen af. */
  111.   Char name[256], invoer[256], wpdef[256], latdef[256], filename[256];
  112.   short l, p;
  113.  
  114.   if (P_argc < 2)
  115.     *wpdef = '\0';
  116.   else
  117.     strcpy(wpdef, P_argv[1]);
  118.  
  119.   printf("\n\nWordPerfect-filename [%s] : ", wpdef);
  120.   gets(invoer);
  121.   if (*invoer == '\0')
  122.     strcpy(wpd_fn, wpdef);
  123.   else
  124.     strcpy(wpd_fn, invoer);
  125.  
  126.   if (*wpd_fn == '\0') {   /* No filename entered */
  127.     RunError(0x200);
  128.   }
  129.  
  130.   strcpy(name, wpd_fn);
  131.   l = strlen(name);
  132.   p = strpos2(name, ".", 1);
  133.   if (p == 0)
  134.     p = l + 1;
  135.   sprintf(filename, "%.*s", p - 1, name);
  136.  
  137.   sprintf(strip_fn, "%s.str", filename);
  138.   sprintf(tabel_fn, "%s.tbl", filename);
  139.   sprintf(latdef, "%s.tex", filename);
  140.  
  141.   printf("LaTeX-filename [%s] : ", latdef);
  142.   gets(invoer);
  143.   putchar('\n');
  144.   if (*invoer == '\0')
  145.     strcpy(latex_fn, latdef);
  146.   else
  147.     strcpy(latex_fn, invoer);
  148.  
  149.   strcpy(wpd_NAME, wpd_fn);
  150.   strcpy(strip_NAME, strip_fn);
  151.   strcpy(tabel_NAME, tabel_fn);
  152.   strcpy(latex_NAME, latex_fn);
  153.  
  154. }
  155.  
  156.  
  157. Static Void Init_commando()
  158. {
  159.   strcpy(open_com[0], "{\\LARGE ");
  160.   strcpy(open_com[0x1], "{\\Large ");
  161.   strcpy(open_com[0x2], "{\\large ");
  162.   strcpy(open_com[0x3], "{\\small ");
  163.   strcpy(open_com[0x4], "{\\footnotesize ");
  164.   strcpy(open_com[0x5], "$^{\\rm ");
  165.   strcpy(open_com[0x6], "$_{\\rm ");
  166.   *open_com[0x7] = '\0';
  167.   strcpy(open_com[0x8], "{\\it ");
  168.   *open_com[0x9] = '\0';
  169.   *open_com[0xa] = '\0';
  170.   strcpy(open_com[0xb], "\\underline{\\Underline{");
  171.   strcpy(open_com[0xc], "{\\bf ");
  172.   *open_com[0xd] = '\0';
  173.   strcpy(open_com[0xe], "\\Underline{");
  174.   strcpy(open_com[0xf], "{\\sc ");
  175.  
  176.   strcpy(close_com[0], "}");
  177.   strcpy(close_com[0x1], "}");
  178.   strcpy(close_com[0x2], "}");
  179.   strcpy(close_com[0x3], "}");
  180.   strcpy(close_com[0x4], "}");
  181.   strcpy(close_com[0x5], "}$");
  182.   strcpy(close_com[0x6], "}$");
  183.   *close_com[0x7] = '\0';
  184.   strcpy(close_com[0x8], "\\/}");
  185.   *close_com[0x9] = '\0';
  186.   *close_com[0xa] = '\0';
  187.   strcpy(close_com[0xb], "}}");
  188.   strcpy(close_com[0xc], "}");
  189.   *close_com[0xd] = '\0';
  190.   strcpy(close_com[0xe], "}");
  191.   strcpy(close_com[0xf], "}");
  192. }
  193.  
  194.  
  195. /* Local variables for Convert_first_strike: */
  196. struct LOC_Convert_first_strike {
  197.   uchar by;
  198.   unsigned short regelnum;
  199.  
  200.   Char lat[0x60][26];
  201.   short char_set[0xff];
  202.   short char_code[0xff];
  203.   Char ext_lat[0xff][26];
  204.  
  205.  
  206.   short leegptr[2], openptr[2];
  207.   uchar attr_rij[2][17];
  208.   boolean open_attr_rij[2];
  209.   short depth;
  210.  
  211.   Char envir, line_term;
  212.  
  213.   boolean char_on_line, nomore_valid_tabs, indenting, indent_end, ind_text1,
  214.       ind_text2;
  215.  
  216.   unsigned short ind_leftmargin, ind_rightmargin;
  217.  
  218.   short num_of_tabs, latex_tabpos;
  219.   unsigned short tabpos[40];
  220.   boolean right_tab, align_tab, center_tab;
  221.  
  222.   short WP_sidemargin;
  223. } ;
  224.  
  225.  
  226.  
  227.  
  228. Local Void WP_Default(LINK)
  229. struct LOC_Convert_first_strike *LINK;
  230. {
  231.   short j;
  232.  
  233.   LINK->WP_sidemargin = 1200;
  234.  
  235.   LINK->tabpos[0] = 0x2c5;   /* 1e WP-tab is kantlijn --> */
  236.   for (j = 2; j <= 10; j++)   /* Volgende tabs 1,5  cm     */
  237.     LINK->tabpos[j - 1] = LINK->tabpos[j - 2] + 0x2c5;
  238.   for (j = 10; j <= 39; j++)   /* ($02c5 wpu) verder        */
  239.     LINK->tabpos[j] = 0xffffL;
  240.  
  241.   LINK->num_of_tabs = 10;
  242. }
  243.  
  244.  
  245. Local Void Table_Init(LINK)
  246. struct LOC_Convert_first_strike *LINK;
  247. {
  248.   strcpy(LINK->lat[0], " ");   /*Space*/
  249.   strcpy(LINK->lat[0x1], "!");   /*!*/
  250.   strcpy(LINK->lat[0x2], "\"");   /*"*/
  251.   strcpy(LINK->lat[0x3], "\\#");   /*#*/
  252.   strcpy(LINK->lat[0x4], "\\$");   /*dollar*/
  253.   strcpy(LINK->lat[0x5], "\\%");   /*%*/
  254.   strcpy(LINK->lat[0x6], "\\&");   /*&*/
  255.   strcpy(LINK->lat[0x7], "'");   /*'*/
  256.   strcpy(LINK->lat[0x8], "(");   /*(*/
  257.   strcpy(LINK->lat[0x9], ")");   /*)*/
  258.   strcpy(LINK->lat[0xa], "*");   /***/
  259.   strcpy(LINK->lat[0xb], "+");   /*+*/
  260.   strcpy(LINK->lat[0xc], ",");   /*,*/
  261.   strcpy(LINK->lat[0xd], "-");   /*-*/
  262.   strcpy(LINK->lat[0xe], ".");   /*.*/
  263.   strcpy(LINK->lat[0xf], "/");   /*/*/
  264.   strcpy(LINK->lat[0x10], "0");   /*0*/
  265.   strcpy(LINK->lat[0x11], "1");   /*1*/
  266.   strcpy(LINK->lat[0x12], "2");   /*2*/
  267.   strcpy(LINK->lat[0x13], "3");   /*3*/
  268.   strcpy(LINK->lat[0x14], "4");   /*4*/
  269.   strcpy(LINK->lat[0x15], "5");   /*5*/
  270.   strcpy(LINK->lat[0x16], "6");   /*6*/
  271.   strcpy(LINK->lat[0x17], "7");   /*7*/
  272.   strcpy(LINK->lat[0x18], "8");   /*8*/
  273.   strcpy(LINK->lat[0x19], "9");   /*9*/
  274.   strcpy(LINK->lat[0x1a], ":");   /*:*/
  275.   strcpy(LINK->lat[0x1b], ";");   /*;*/
  276.   strcpy(LINK->lat[0x1c], "$<$");   /*<*/
  277.   strcpy(LINK->lat[0x1d], "=");   /*=*/
  278.   strcpy(LINK->lat[0x1e], "$>$");   /*>*/
  279.   strcpy(LINK->lat[0x1f], "?");   /*?*/
  280.   strcpy(LINK->lat[0x20], "@");   /*@*/
  281.   strcpy(LINK->lat[0x21], "A");   /*A*/
  282.   strcpy(LINK->lat[0x22], "B");   /*B*/
  283.   strcpy(LINK->lat[0x23], "C");   /*C*/
  284.   strcpy(LINK->lat[0x24], "D");   /*D*/
  285.   strcpy(LINK->lat[0x25], "E");   /*E*/
  286.   strcpy(LINK->lat[0x26], "F");   /*F*/
  287.   strcpy(LINK->lat[0x27], "G");   /*G*/
  288.   strcpy(LINK->lat[0x28], "H");   /*H*/
  289.   strcpy(LINK->lat[0x29], "I");   /*I*/
  290.   strcpy(LINK->lat[0x2a], "J");   /*J*/
  291.   strcpy(LINK->lat[0x2b], "K");   /*K*/
  292.   strcpy(LINK->lat[0x2c], "L");   /*L*/
  293.   strcpy(LINK->lat[0x2d], "M");   /*M*/
  294.   strcpy(LINK->lat[0x2e], "N");   /*N*/
  295.   strcpy(LINK->lat[0x2f], "O");   /*O*/
  296.   strcpy(LINK->lat[0x30], "P");   /*P*/
  297.   strcpy(LINK->lat[0x31], "Q");   /*Q*/
  298.   strcpy(LINK->lat[0x32], "R");   /*R*/
  299.   strcpy(LINK->lat[0x33], "S");   /*S*/
  300.   strcpy(LINK->lat[0x34], "T");   /*T*/
  301.   strcpy(LINK->lat[0x35], "U");   /*U*/
  302.   strcpy(LINK->lat[0x36], "V");   /*V*/
  303.   strcpy(LINK->lat[0x37], "W");   /*W*/
  304.   strcpy(LINK->lat[0x38], "X");   /*X*/
  305.   strcpy(LINK->lat[0x39], "Y");   /*Y*/
  306.   strcpy(LINK->lat[0x3a], "Z");   /*Z*/
  307.   strcpy(LINK->lat[0x3b], "[");   /*[*/
  308.   strcpy(LINK->lat[0x3c], "$\\tt\\backslash$");   /*\*/
  309.   strcpy(LINK->lat[0x3d], "]");   /*]*/
  310.   strcpy(LINK->lat[0x3e], "\\^{");   /*^*/
  311.   strcpy(LINK->lat[0x3f], "\\_");   /*_*/
  312.   strcpy(LINK->lat[0x40], "`");   /*`*/
  313.   strcpy(LINK->lat[0x41], "a");   /*a*/
  314.   strcpy(LINK->lat[0x42], "b");   /*b*/
  315.   strcpy(LINK->lat[0x43], "c");   /*c*/
  316.   strcpy(LINK->lat[0x44], "d");   /*d*/
  317.   strcpy(LINK->lat[0x45], "e");   /*e*/
  318.   strcpy(LINK->lat[0x46], "f");   /*f*/
  319.   strcpy(LINK->lat[0x47], "g");   /*g*/
  320.   strcpy(LINK->lat[0x48], "h");   /*h*/
  321.   strcpy(LINK->lat[0x49], "i");   /*i*/
  322.   strcpy(LINK->lat[0x4a], "j");   /*j*/
  323.   strcpy(LINK->lat[0x4b], "k");   /*k*/
  324.   strcpy(LINK->lat[0x4c], "l");   /*l*/
  325.   strcpy(LINK->lat[0x4d], "m");   /*m*/
  326.   strcpy(LINK->lat[0x4e], "n");   /*n*/
  327.   strcpy(LINK->lat[0x4f], "o");   /*o*/
  328.   strcpy(LINK->lat[0x50], "p");   /*p*/
  329.   strcpy(LINK->lat[0x51], "q");   /*q*/
  330.   strcpy(LINK->lat[0x52], "r");   /*r*/
  331.   strcpy(LINK->lat[0x53], "s");   /*s*/
  332.   strcpy(LINK->lat[0x54], "t");   /*t*/
  333.   strcpy(LINK->lat[0x55], "u");   /*u*/
  334.   strcpy(LINK->lat[0x56], "v");   /*v*/
  335.   strcpy(LINK->lat[0x57], "w");   /*w*/
  336.   strcpy(LINK->lat[0x58], "x");   /*x*/
  337.   strcpy(LINK->lat[0x59], "y");   /*y*/
  338.   strcpy(LINK->lat[0x5a], "z");   /*z*/
  339.   strcpy(LINK->lat[0x5b], "\\{");   /*{*/
  340.   strcpy(LINK->lat[0x5c], "$|$");   /*|*/
  341.   strcpy(LINK->lat[0x5d], "\\}");   /* */
  342.   strcpy(LINK->lat[0x5e], "\\tidle{");   /*~*/
  343.   strcpy(LINK->lat[0x5f], " ");   /*Doesn't exsist*/
  344. }
  345.  
  346.  
  347. Local Void Ext_chr_init(LINK)
  348. struct LOC_Convert_first_strike *LINK;
  349. {
  350.   LINK->char_set[0] = 0x1;
  351.   LINK->char_code[0] = 0x26;
  352.   strcpy(LINK->ext_lat[0], "\\c{C}");
  353.   LINK->char_set[0x1] = 0x1;
  354.   LINK->char_code[0x1] = 0x47;
  355.   strcpy(LINK->ext_lat[0x1], "\\\"{u}");
  356.   LINK->char_set[0x2] = 0x1;
  357.   LINK->char_code[0x2] = 0x29;
  358.   strcpy(LINK->ext_lat[0x2], "\\'{e}");
  359.   LINK->char_set[0x3] = 0x1;
  360.   LINK->char_code[0x3] = 0x1d;
  361.   strcpy(LINK->ext_lat[0x3], "\\^{a}");
  362.   LINK->char_set[0x4] = 0x1;
  363.   LINK->char_code[0x4] = 0x1f;
  364.   strcpy(LINK->ext_lat[0x4], "\\\"{a}");
  365.   LINK->char_set[0x5] = 0x1;
  366.   LINK->char_code[0x5] = 0x21;
  367.   strcpy(LINK->ext_lat[0x5], "\\`{a}");
  368.   LINK->char_set[0x6] = 0x1;
  369.   LINK->char_code[0x6] = 0x23;
  370.   strcpy(LINK->ext_lat[0x6], "\\aa ");
  371.   LINK->char_set[0x7] = 0x1;
  372.   LINK->char_code[0x7] = 0x27;
  373.   strcpy(LINK->ext_lat[0x7], "\\c{c}");
  374.   LINK->char_set[0x8] = 0x1;
  375.   LINK->char_code[0x8] = 0x2b;
  376.   strcpy(LINK->ext_lat[0x8], "\\^{e}");
  377.   LINK->char_set[0x9] = 0x1;
  378.   LINK->char_code[0x9] = 0x2d;
  379.   strcpy(LINK->ext_lat[0x9], "\\\"{e}");
  380.   LINK->char_set[0xa] = 0x1;
  381.   LINK->char_code[0xa] = 0x2f;
  382.   strcpy(LINK->ext_lat[0xa], "\\`{e}");
  383.   LINK->char_set[0xb] = 0x1;
  384.   LINK->char_code[0xb] = 0x35;
  385.   strcpy(LINK->ext_lat[0xb], "\\\"{\\i}");
  386.   LINK->char_set[0xc] = 0x1;
  387.   LINK->char_code[0xc] = 0x33;
  388.   strcpy(LINK->ext_lat[0xc], "\\^{\\i}");
  389.   LINK->char_set[0xd] = 0x1;
  390.   LINK->char_code[0xd] = 0x37;
  391.   strcpy(LINK->ext_lat[0xd], "\\`{\\i}");
  392.   LINK->char_set[0xe] = 0x1;
  393.   LINK->char_code[0xe] = 0x1e;
  394.   strcpy(LINK->ext_lat[0xe], "\\\"{A}");
  395.   LINK->char_set[0xf] = 0x1;
  396.   LINK->char_code[0xf] = 0x22;
  397.   strcpy(LINK->ext_lat[0xf], "\\AA ");
  398.   LINK->char_set[0x10] = 0x1;
  399.   LINK->char_code[0x10] = 0x28;
  400.   strcpy(LINK->ext_lat[0x10], "\\'{E}");
  401.   LINK->char_set[0x11] = 0x1;
  402.   LINK->char_code[0x11] = 0x25;
  403.   strcpy(LINK->ext_lat[0x11], "\\ae ");
  404.   LINK->char_set[0x12] = 0x1;
  405.   LINK->char_code[0x12] = 0x24;
  406.   strcpy(LINK->ext_lat[0x12], "\\AE ");
  407.   LINK->char_set[0x13] = 0x1;
  408.   LINK->char_code[0x13] = 0x3d;
  409.   strcpy(LINK->ext_lat[0x13], "\\^{o}");
  410.   LINK->char_set[0x14] = 0x1;
  411.   LINK->char_code[0x14] = 0x3f;
  412.   strcpy(LINK->ext_lat[0x14], "\\\"{o}");
  413.   LINK->char_set[0x15] = 0x1;
  414.   LINK->char_code[0x15] = 0x41;
  415.   strcpy(LINK->ext_lat[0x15], "\\`{o}");
  416.   LINK->char_set[0x16] = 0x1;
  417.   LINK->char_code[0x16] = 0x45;
  418.   strcpy(LINK->ext_lat[0x16], "\\^{u}");
  419.   LINK->char_set[0x17] = 0x1;
  420.   LINK->char_code[0x17] = 0x49;
  421.   strcpy(LINK->ext_lat[0x17], "\\`{u}");
  422.   LINK->char_set[0x18] = 0x1;
  423.   LINK->char_code[0x18] = 0x8b;
  424.   strcpy(LINK->ext_lat[0x18], "\\\"{y}");
  425.   LINK->char_set[0x19] = 0x1;
  426.   LINK->char_code[0x19] = 0x3e;
  427.   strcpy(LINK->ext_lat[0x19], "\\\"{O}");
  428.   LINK->char_set[0x1a] = 0x1;
  429.   LINK->char_code[0x1a] = 0x46;
  430.   strcpy(LINK->ext_lat[0x1a], "\\\"{U}");
  431.   LINK->char_set[0x1b] = 0x4;
  432.   LINK->char_code[0x1b] = 0x13;
  433.   strcpy(LINK->ext_lat[0x1b], "\\ ");
  434.   LINK->char_set[0x1c] = 0x4;
  435.   LINK->char_code[0x1c] = 0xb;
  436.   strcpy(LINK->ext_lat[0x1c], "\\pounds ");
  437.   LINK->char_set[0x1d] = 0x4;
  438.   LINK->char_code[0x1d] = 0xc;
  439.   strcpy(LINK->ext_lat[0x1d], "\\ ");
  440.   LINK->char_set[0x1e] = 0x4;
  441.   LINK->char_code[0x1e] = 0xd;
  442.   strcpy(LINK->ext_lat[0x1e], "\\ ");
  443.   LINK->char_set[0x1f] = 0x4;
  444.   LINK->char_code[0x1f] = 0xe;
  445.   strcpy(LINK->ext_lat[0x1f], "{\\it f}\\/");
  446.   LINK->char_set[0x20] = 0x1;
  447.   LINK->char_code[0x20] = 0x1b;
  448.   strcpy(LINK->ext_lat[0x20], "\\'{a}");
  449.   LINK->char_set[0x21] = 0x1;
  450.   LINK->char_code[0x21] = 0x31;
  451.   strcpy(LINK->ext_lat[0x21], "\\'{\\i}");
  452.   LINK->char_set[0x22] = 0x1;
  453.   LINK->char_code[0x22] = 0x3b;
  454.   strcpy(LINK->ext_lat[0x22], "\\'{o}");
  455.   LINK->char_set[0x23] = 0x1;
  456.   LINK->char_code[0x23] = 0x43;
  457.   strcpy(LINK->ext_lat[0x23], "\\'{u}");
  458.   LINK->char_set[0x24] = 0x1;
  459.   LINK->char_code[0x24] = 0x39;
  460.   strcpy(LINK->ext_lat[0x24], "\\~{n}");
  461.   LINK->char_set[0x25] = 0x1;
  462.   LINK->char_code[0x25] = 0x38;
  463.   strcpy(LINK->ext_lat[0x25], "\\~{N}");
  464.   LINK->char_set[0x26] = 0x4;
  465.   LINK->char_code[0x26] = 0xf;
  466.   strcpy(LINK->ext_lat[0x26], "\\astrike ");
  467.   LINK->char_set[0x27] = 0x4;
  468.   LINK->char_code[0x27] = 0x10;
  469.   strcpy(LINK->ext_lat[0x27], "\\ostrike ");
  470.   LINK->char_set[0x28] = 0x4;
  471.   LINK->char_code[0x28] = 0x8;
  472.   strcpy(LINK->ext_lat[0x28], "?`");
  473.   LINK->char_set[0x29] = 0x5;
  474.   LINK->char_code[0x29] = 0x10;
  475.   strcpy(LINK->ext_lat[0x29], "~");
  476.   LINK->char_set[0x2a] = 0x6;
  477.   LINK->char_code[0x2a] = 0x14;
  478.   strcpy(LINK->ext_lat[0x2a], "~");
  479.   LINK->char_set[0x2b] = 0x4;
  480.   LINK->char_code[0x2b] = 0x11;
  481.   strcpy(LINK->ext_lat[0x2b], "$\\frac{1}{2}$");
  482.   LINK->char_set[0x2c] = 0x4;
  483.   LINK->char_code[0x2c] = 0x12;
  484.   strcpy(LINK->ext_lat[0x2c], "$\\frac{1}{4}$");
  485.   LINK->char_set[0x2d] = 0x4;
  486.   LINK->char_code[0x2d] = 0x7;
  487.   strcpy(LINK->ext_lat[0x2d], "!`");
  488.   LINK->char_set[0x2e] = 0x4;
  489.   LINK->char_code[0x2e] = 0x9;
  490.   strcpy(LINK->ext_lat[0x2e], "$\\ll$");
  491.   LINK->char_set[0x2f] = 0x4;
  492.   LINK->char_code[0x2f] = 0xa;
  493.   strcpy(LINK->ext_lat[0x2f], "$\\gg$");
  494.   LINK->char_set[0x60] = 0x8;
  495.   LINK->char_code[0x60] = 0x1;
  496.   strcpy(LINK->ext_lat[0x60], "$\\alpha$");
  497.   /*
  498.   These are wrong
  499.   LINK->char_set[0x61] = 0x1;
  500.   LINK->char_code[0x61] = 0x17;
  501.   They originally were used to detect beta
  502.   */
  503.   LINK->char_set[0x61] = 0x08;
  504.   LINK->char_code[0x61] = 0x03;
  505.   strcpy(LINK->ext_lat[0x61], "$\\beta$");
  506.   LINK->char_set[0x62] = 0x8;
  507.   LINK->char_code[0x62] = 0x6;
  508.   strcpy(LINK->ext_lat[0x62], "$\\Gamma$");
  509.   LINK->char_set[0x63] = 0x8;
  510.   LINK->char_code[0x63] = 0x21;
  511.   strcpy(LINK->ext_lat[0x63], "$\\pi$");
  512.   LINK->char_set[0x64] = 0x8;
  513.   LINK->char_code[0x64] = 0x24;
  514.   strcpy(LINK->ext_lat[0x64], "$\\Sigma$");
  515.   LINK->char_set[0x65] = 0x8;
  516.   LINK->char_code[0x65] = 0x25;
  517.   strcpy(LINK->ext_lat[0x65], "$\\sigma$");
  518.   LINK->char_set[0x66] = 0x8;
  519.   LINK->char_code[0x66] = 0x19;
  520.   strcpy(LINK->ext_lat[0x66], "$\\mu$");
  521.   LINK->char_set[0x67] = 0x8;
  522.   LINK->char_code[0x67] = 0x29;
  523.   strcpy(LINK->ext_lat[0x67], "$\\tau$");
  524.   LINK->char_set[0x68] = 0x8;
  525.   LINK->char_code[0x68] = 0x2c;
  526.   strcpy(LINK->ext_lat[0x68], "$\\Phi$");
  527.   LINK->char_set[0x69] = 0x8;
  528.   LINK->char_code[0x69] = 0x10;
  529.   strcpy(LINK->ext_lat[0x69], "$\\theta$");
  530.   LINK->char_set[0x6a] = 0x8;
  531.   LINK->char_code[0x6a] = 0x32;
  532.   strcpy(LINK->ext_lat[0x6a], "$\\Omega$");
  533.   LINK->char_set[0x6b] = 0x8;
  534.   LINK->char_code[0x6b] = 0x9;
  535.   strcpy(LINK->ext_lat[0x6b], "$\\delta$");
  536.   LINK->char_set[0x6c] = 0x6;
  537.   LINK->char_code[0x6c] = 0x13;
  538.   strcpy(LINK->ext_lat[0x6c], "$\\infty$");
  539.   LINK->char_set[0x6d] = 0x8;
  540.   LINK->char_code[0x6d] = 0x2d;
  541.   strcpy(LINK->ext_lat[0x6d], "$\\emptyset$");
  542.   LINK->char_set[0x6e] = 0x8;
  543.   LINK->char_code[0x6e] = 0xb;
  544.   strcpy(LINK->ext_lat[0x6e], "$\\epsilon$");
  545.   LINK->char_set[0x6f] = 0x6;
  546.   LINK->char_code[0x6f] = 0x10;
  547.   strcpy(LINK->ext_lat[0x6f], "$\\cap$");
  548.   LINK->char_set[0x70] = 0x6;
  549.   LINK->char_code[0x70] = 0xe;
  550.   strcpy(LINK->ext_lat[0x70], "$\\equiv$");
  551.   LINK->char_set[0x71] = 0x6;
  552.   LINK->char_code[0x71] = 0x1;
  553.   strcpy(LINK->ext_lat[0x71], "$\\pm$");
  554.   LINK->char_set[0x72] = 0x6;
  555.   LINK->char_code[0x72] = 0x3;
  556.   strcpy(LINK->ext_lat[0x72], "$\\geq$");
  557.   LINK->char_set[0x73] = 0x6;
  558.   LINK->char_code[0x73] = 0x2;
  559.   strcpy(LINK->ext_lat[0x73], "$\\leq$");
  560.   LINK->char_set[0x74] = 0x7;
  561.   LINK->char_code[0x74] = 0;
  562.   strcpy(LINK->ext_lat[0x74], "~");
  563.   LINK->char_set[0x75] = 0x7;
  564.   LINK->char_code[0x75] = 0x1;
  565.   strcpy(LINK->ext_lat[0x75], "~");
  566.   LINK->char_set[0x76] = 0x6;
  567.   LINK->char_code[0x76] = 0x8;
  568.   strcpy(LINK->ext_lat[0x76], "$\\div$");
  569.   LINK->char_set[0x77] = 0x6;
  570.   LINK->char_code[0x77] = 0xd;
  571.   strcpy(LINK->ext_lat[0x77], "$\\approx$");
  572.   LINK->char_set[0x78] = 0x6;
  573.   LINK->char_code[0x78] = 0x24;
  574.   strcpy(LINK->ext_lat[0x78], "\\degrees ");
  575.   LINK->char_set[0x79] = 0x6;
  576.   LINK->char_code[0x79] = 0x1f;
  577.   strcpy(LINK->ext_lat[0x79], "~");
  578.   LINK->char_set[0x7a] = 0x6;
  579.   LINK->char_code[0x7a] = 0x20;
  580.   strcpy(LINK->ext_lat[0x7a], "~");
  581.   LINK->char_set[0x7b] = 0x7;
  582.   LINK->char_code[0x7b] = 0x4;
  583.   strcpy(LINK->ext_lat[0x7b], "$\\surd$");
  584.   LINK->char_set[0x7c] = 0x4;
  585.   LINK->char_code[0x7c] = 0x15;
  586.   strcpy(LINK->ext_lat[0x7c], "$^{n}$");
  587.   LINK->char_set[0x7d] = 0x4;
  588.   LINK->char_code[0x7d] = 0x14;
  589.   strcpy(LINK->ext_lat[0x7d], "$^{2}$");
  590.   LINK->char_set[0x7e] = 0x4;
  591.   LINK->char_code[0x7e] = 0x2;
  592.   strcpy(LINK->ext_lat[0x7e], "~");
  593. /*
  594. ** Note: Adding characters is easy. The maximum available is
  595. ** now 256 not 128 (Pascal version).
  596. ** e.g. The Greek character set is char_set 0x8,
  597. ** \Alpha has char_code 0x0, \alpha has char_code 0x1 ...
  598. ** \Omega has char_code 0x32 and \omega has char_code 0x33
  599. ** I suspect that there are two versions of some letters
  600. ** I've only added the ones I've needed for translating.
  601. ** Hence the apparent randomness.
  602. */
  603.   LINK->char_set[0x7f] = 0x8;
  604.   LINK->char_code[0x7f] = 0x15;
  605.   strcpy(LINK->ext_lat[0x7f], "$\\kappa$");
  606.   LINK->char_set[0x80] = 0x8;
  607.   LINK->char_code[0x80] = 0x8;
  608.   strcpy(LINK->ext_lat[0x80], "$\\Delta$");
  609.   LINK->char_set[0x81] = 0x8;
  610.   LINK->char_code[0x81] = 0xf;
  611.   strcpy(LINK->ext_lat[0x81], "$\\eta$");
  612.   LINK->char_set[0x82] = 0x8;
  613.   LINK->char_code[0x82] = 0x27;
  614.   strcpy(LINK->ext_lat[0x82], "$\\zeta$");
  615.   LINK->char_set[0x83] = 0x06;
  616.   LINK->char_code[0x83] = 0x0a;
  617.   strcpy(LINK->ext_lat[0x83], "$<$");
  618.   LINK->char_set[0x84] = 0x06;
  619.   LINK->char_code[0x84] = 0x09;
  620.   strcpy(LINK->ext_lat[0x84], "$|$");
  621.   LINK->char_set[0x85] = 0x8;
  622.   LINK->char_code[0x85] = 0x7;
  623.   strcpy(LINK->ext_lat[0x85], "$\\gamma$");
  624.   LINK->char_set[0x86] = 0x8;
  625.   LINK->char_code[0x86] = 0x2b;
  626.   strcpy(LINK->ext_lat[0x86], "$\\phi$");
  627.   LINK->char_set[0x87] = 0x6;
  628.   LINK->char_code[0x87] = 0x27;
  629.   strcpy(LINK->ext_lat[0x87], "$\\times$");
  630.   LINK->char_set[0x88] = 0x6;
  631.   LINK->char_code[0x88] = 0x28;
  632.   strcpy(LINK->ext_lat[0x88], "$\\int$");
  633.   LINK->char_set[0x89] = 0x8;
  634.   LINK->char_code[0x89] = 0x31;
  635.   strcpy(LINK->ext_lat[0x89], "$\\psi$");
  636.   LINK->char_set[0x8a] = 0x6;
  637.   LINK->char_code[0x8a] = 0xb;
  638.   strcpy(LINK->ext_lat[0x8a], "$>$");
  639.   LINK->char_set[0x8b] = 0x8;
  640.   LINK->char_code[0x8b] = 0x2f;
  641.   strcpy(LINK->ext_lat[0x8b], "$\\chi$");
  642.   LINK->char_set[0x8c] = 0x6;
  643.   LINK->char_code[0x8c] = 0x17;
  644.   strcpy(LINK->ext_lat[0x8c], "$\\uparrow$");
  645.   LINK->char_set[0x8d] = 0x6;
  646.   LINK->char_code[0x8d] = 0x15;
  647.   strcpy(LINK->ext_lat[0x8d], "$\\rightarrow$");
  648.   LINK->char_set[0x8e] = 0x8;
  649.   LINK->char_code[0x8e] = 0x17;
  650.   strcpy(LINK->ext_lat[0x8e], "$\\lambda$");
  651.   LINK->char_set[0x8f] = 0x8;
  652.   LINK->char_code[0x8f] = 0x33;
  653.   strcpy(LINK->ext_lat[0x8f], "$\\omega$");
  654.   LINK->char_set[0x90] = 0x6;
  655.   LINK->char_code[0x90] = 0x2b;
  656.   strcpy(LINK->ext_lat[0x90], "$\\nabla$");
  657. }
  658.  
  659.  
  660. Local Void Make_tabelentry_attr(LINK)
  661. struct LOC_Convert_first_strike *LINK;
  662. {
  663.   uchar num_of_attr;
  664.   short j;
  665.  
  666.   num_of_attr = LINK->openptr[LINK->depth];
  667.   fwrite(&num_of_attr, sizeof(uchar), 1, tabel);
  668.  
  669.   for (j = 1; j <= num_of_attr; j++)
  670.     fwrite(&LINK->attr_rij[LINK->depth][j], sizeof(uchar), 1, tabel);
  671.  
  672. }
  673.  
  674.  
  675.  
  676. Local Void Make_tabelentry_tabset(LINK)
  677. struct LOC_Convert_first_strike *LINK;
  678. {
  679.   uchar b;
  680.   short j, FORLIM;
  681.  
  682.   b = 'S';
  683.   fwrite(&b, sizeof(uchar), 1, tabel);
  684.  
  685.   b = LINK->num_of_tabs;
  686.   fwrite(&b, sizeof(uchar), 1, tabel);
  687.  
  688.   FORLIM = LINK->num_of_tabs;
  689.   for (j = 0; j < FORLIM; j++)
  690.     Wr_word(&tabel, LINK->tabpos[j]);
  691. }
  692.  
  693.  
  694. Local Void Make_tabelentry_rightjustification(LINK)
  695. struct LOC_Convert_first_strike *LINK;
  696. {
  697.   uchar b;
  698.  
  699.   b = 'U';
  700.   fwrite(&b, sizeof(uchar), 1, tabel);
  701.  
  702.   if (LINK->by == 0x81)   /* regels NIET uitvullen */
  703.     b = 1;   /* regels WEL uitvullen */
  704.   else
  705.     b = 0;
  706.   fwrite(&b, sizeof(uchar), 1, tabel);
  707. }
  708.  
  709.  
  710.  
  711.  
  712. Local Void Make_tabelentry_envir_extra_end(LINK)
  713. struct LOC_Convert_first_strike *LINK;
  714. {
  715.   uchar b;
  716.  
  717.  
  718.   switch (LINK->envir) {
  719.  
  720.   case 'C':
  721.     b = 'C';
  722.     fwrite(&b, sizeof(uchar), 1, tabel);
  723.     break;
  724.  
  725.   case 'T':
  726.     b = 'T';
  727.     fwrite(&b, sizeof(uchar), 1, tabel);
  728.     break;
  729.  
  730.   case 'I':
  731.     b = 'I';
  732.     fwrite(&b, sizeof(uchar), 1, tabel);
  733.     Wr_word(&tabel, LINK->ind_leftmargin);
  734.     Wr_word(&tabel, LINK->ind_rightmargin);
  735.  
  736.     if (LINK->ind_text2) {
  737.       b = 1;
  738.       fwrite(&b, sizeof(uchar), 1, tabel);
  739.     } else {
  740.       b = 0;
  741.       fwrite(&b, sizeof(uchar), 1, tabel);
  742.     }
  743.  
  744.     break;
  745.  
  746.   }/*Case*/
  747.  
  748.   b = LINK->line_term;
  749.   fwrite(&b, sizeof(uchar), 1, tabel);
  750.  
  751.   b = 0xff;
  752.   fwrite(&b, sizeof(uchar), 1, tabel);
  753.  
  754. }
  755.  
  756.  
  757. Local Void Reset_attr_rij(d, LINK)
  758. short d;
  759. struct LOC_Convert_first_strike *LINK;
  760. {
  761.   short j;
  762.  
  763.   for (j = 0; j <= 16; j++)
  764.     LINK->attr_rij[d][j] = 0;
  765.   LINK->leegptr[d] = 1;
  766.   LINK->openptr[d] = 0;
  767. }
  768.  
  769.  
  770.  
  771. Local Void Open_all_attr(LINK)
  772. struct LOC_Convert_first_strike *LINK;
  773. {
  774.   /* -- Open alle commando's door de Attributen-rij af te lopen -- */
  775.   short j, FORLIM;
  776.  
  777.   FORLIM = LINK->leegptr[LINK->depth];
  778.   for (j = LINK->openptr[LINK->depth] + 1; j < FORLIM; j++) {
  779.     fputs(open_com[LINK->attr_rij[LINK->depth][j]], strip);
  780.     LINK->openptr[LINK->depth]++;
  781.   }
  782.  
  783.   LINK->open_attr_rij[LINK->depth] = false;
  784.       /* Alle attributen staan weer goed */
  785. }
  786.  
  787.  
  788.  
  789. Local Void Close_all_attr(LINK)
  790. struct LOC_Convert_first_strike *LINK;
  791. {
  792.   /* -- Sluit alle commando's door de Attributen-rij af te lopen -- */
  793.   short j;
  794.  
  795.   for (j = LINK->openptr[LINK->depth]; j >= 1; j--) {
  796.     fputs(close_com[LINK->attr_rij[LINK->depth][j]], strip);
  797.     LINK->openptr[LINK->depth]--;
  798.   }
  799.   LINK->open_attr_rij[LINK->depth] = true;
  800. }
  801.  
  802.  
  803.  
  804. Local Void Attr_ON(LINK)
  805. struct LOC_Convert_first_strike *LINK;
  806. {
  807.   /* Deze procedure plaatst een attribuut (lettertype) in de attribuut-rij */
  808.   uchar b;
  809.  
  810.   fread(&b, sizeof(uchar), 1, wpd);   /* lees attribuut-code */
  811.  
  812.   LINK->attr_rij[LINK->depth][LINK->leegptr[LINK->depth]] = b;
  813.       /* attribuut in attr-rij */
  814.   LINK->leegptr[LINK->depth]++;   /* plaats 1 verder. */
  815.   LINK->open_attr_rij[LINK->depth] = true;   /* openstaande attr-rij */
  816.  
  817.   fread(&b, sizeof(uchar), 1, wpd);   /* lees voorbij afsluitcode */
  818. }
  819.  
  820.  
  821.  
  822. Local Void Attr_OFF(LINK)
  823. struct LOC_Convert_first_strike *LINK;
  824. {
  825.   /* Deze procedure haalt een uit een attribuut (lettertype) uit de */
  826.   /* attribuut-rij door middel van een stack principe omdat binnen  */
  827.   /* LaTeX de later geopende kommando's eerst afgesloten te worden  */
  828.   uchar b;
  829.   boolean found;
  830.   short j, codeptr, FORLIM;
  831.  
  832.   fread(&b, sizeof(uchar), 1, wpd);   /* lees attribuut-code */
  833.  
  834.   j = LINK->leegptr[LINK->depth];   /* zoek vanaf top attr-rij */
  835.   found = false;   /* nog niet gevonden */
  836.  
  837.   while (j > 1 && !found) {   /* zoek attr-code in attr-rij */
  838.     j--;
  839.     found = (LINK->attr_rij[LINK->depth][j] == b);
  840.   }
  841.  
  842.   if (j <= 0) {   /* Moet nooit kunnen voorkomen */
  843.     RunError(0x100);
  844.   }
  845.   codeptr = j;   /* plaats van attr-code in rij */
  846.  
  847.   /* Sluit alle commando's t/m de desbetreffende code als deze nog niet */
  848.   /* gesloten zijn.                                                     */
  849.  
  850.   if (codeptr <= LINK->openptr[LINK->depth]) {
  851.     for (j = LINK->openptr[LINK->depth]; j >= codeptr; j--) {
  852.       fputs(close_com[LINK->attr_rij[LINK->depth][j]], strip);
  853.       LINK->openptr[LINK->depth]--;
  854.     }
  855.   }
  856.  
  857.   FORLIM = LINK->leegptr[LINK->depth];
  858.   /* Haal de desbetreffende attribuut uit de rij en werk pointers bij */
  859.  
  860.   for (j = codeptr; j < FORLIM; j++)
  861.     LINK->attr_rij[LINK->depth][j] = LINK->attr_rij[LINK->depth][j + 1];
  862.   LINK->leegptr[LINK->depth]--;
  863.  
  864.   LINK->open_attr_rij[LINK->depth] = true;   /* openstaande attr-rij */
  865.  
  866.   fread(&b, sizeof(uchar), 1, wpd);   /* lees voorbij afsluitcode */
  867. }
  868.  
  869.  
  870.  
  871. Local Void Center(LINK)
  872. struct LOC_Convert_first_strike *LINK;
  873. {
  874.   /* Deze procedure zorgt voor center environment zolang er nog geen */
  875.   /* andere environment is begonnen.                                 */
  876.   if (LINK->envir == ' ')   /* environment = center */
  877.     LINK->envir = 'C';
  878.  
  879.   Jump_in_file(&wpd, 7L);   /* rest van code overslaan */
  880. }
  881.  
  882.  
  883.  
  884. Local Void End_Align(LINK)
  885. struct LOC_Convert_first_strike *LINK;
  886. {
  887.   if (LINK->align_tab) {
  888.     Close_all_attr(LINK);
  889.     fprintf(strip, "\\'");
  890.     LINK->align_tab = false;
  891.     Open_all_attr(LINK);
  892.   }
  893.  
  894.   if (LINK->right_tab) {
  895.     Close_all_attr(LINK);
  896.     fprintf(strip, "\\'");
  897.     LINK->right_tab = false;
  898.     Open_all_attr(LINK);
  899.   }
  900.  
  901.   if (!LINK->center_tab)
  902.     return;
  903.   Close_all_attr(LINK);
  904.   putc('}', strip);
  905.   LINK->center_tab = false;
  906.   Open_all_attr(LINK);
  907. }
  908.  
  909.  
  910.  
  911. Local Void Tab(LINK)
  912. struct LOC_Convert_first_strike *LINK;
  913. {
  914.   short j;
  915.   unsigned short wpu;
  916.   short tabnum, new_tabs, FORLIM;
  917.  
  918.   if (LINK->envir == 'I' || LINK->nomore_valid_tabs)
  919.   {   /* Noggeen indent --> normaal tab */
  920.     Jump_in_file(&wpd, 7L);
  921.     return;
  922.   }
  923.  
  924.  
  925.   if (LINK->by == 0x48)
  926.     LINK->right_tab = true;
  927.  
  928.   if (LINK->by == 0x40)
  929.     LINK->align_tab = true;
  930.  
  931.   if (LINK->by == 0xc8)
  932.     LINK->center_tab = true;
  933.  
  934.   Jump_in_file(&wpd, 2L);
  935.  
  936.   Rd_word(&wpd, &wpu);   /* Lees abs.-indent [wpu] */
  937.   wpu -= LINK->WP_sidemargin;   /* Correctie ivm WP kantlijn */
  938.  
  939.   tabnum = 0;
  940.   FORLIM = LINK->num_of_tabs;
  941.   for (j = 1; j <= FORLIM; j++) {   /* Bepaal welke tabpos */
  942.     if (wpu >= LINK->tabpos[j - 1])
  943.       tabnum = j;
  944.   }
  945.  
  946.   new_tabs = tabnum - LINK->latex_tabpos;
  947.  
  948.   if (new_tabs > 0) {
  949.     Close_all_attr(LINK);
  950.  
  951.     for (j = 1; j <= new_tabs; j++)
  952.       fprintf(strip, "\\>");
  953.  
  954.     if (LINK->center_tab)
  955.       fprintf(strip, "\\ctab{");
  956.  
  957.     Open_all_attr(LINK);
  958.   }
  959.  
  960.   LINK->latex_tabpos = tabnum;
  961.  
  962.   Jump_in_file(&wpd, 3L);
  963.  
  964.   LINK->envir = 'T';   /* Er zit een tab in deze regel */
  965. }
  966.  
  967.  
  968.  
  969. Local Void Flush_right_tab(LINK)
  970. struct LOC_Convert_first_strike *LINK;
  971. {
  972.   if (LINK->envir != 'I') {
  973.     Close_all_attr(LINK);
  974.     fprintf(strip, "\\`");
  975.     Open_all_attr(LINK);
  976.  
  977.     LINK->nomore_valid_tabs = true;
  978.  
  979.     LINK->envir = 'T';
  980.   }
  981.  
  982.   Jump_in_file(&wpd, 7L);
  983. }
  984.  
  985.  
  986.  
  987. Local Void Indent(LINK)
  988. struct LOC_Convert_first_strike *LINK;
  989. {
  990.   unsigned short dif, abs;
  991.   uchar b;
  992.  
  993.   if (LINK->envir == 'T') {
  994.     /*Al een tabcommando gezet dus er mag geen insp */
  995.       Jump_in_file(&wpd, 10L);
  996.     return;
  997.   }
  998.   LINK->envir = 'I';
  999.   LINK->indenting = true;
  1000.  
  1001.   if (LINK->ind_text2) {
  1002.     Jump_in_file(&wpd, 10L);
  1003.     return;
  1004.   }
  1005.   fread(&b, sizeof(uchar), 1, wpd);
  1006.   b &= 0x1;
  1007.  
  1008.   Rd_word(&wpd, &dif);
  1009.   Rd_word(&wpd, &abs);   /* Eigenlijk Old current column */
  1010.   Rd_word(&wpd, &abs);
  1011.  
  1012.   LINK->ind_leftmargin = abs - LINK->WP_sidemargin;
  1013.  
  1014.   if (b == 1)
  1015.     LINK->ind_rightmargin += dif;
  1016.   /*Margins bepaald lees voorby rest van functie-codes */
  1017.   Jump_in_file(&wpd, 3L);
  1018.  
  1019.   if (LINK->ind_text1)
  1020.     return;
  1021.   if (LINK->char_on_line) {
  1022.     putc('}', strip);
  1023.     LINK->ind_text1 = true;
  1024.   }
  1025. }
  1026.  
  1027.  
  1028. Local Void End_of_indent(LINK)
  1029. struct LOC_Convert_first_strike *LINK;
  1030. {
  1031.   LINK->indent_end = true;
  1032.   Jump_in_file(&wpd, 5L);
  1033. }
  1034.  
  1035.  
  1036.  
  1037. Local Void Tabset(LINK)
  1038. struct LOC_Convert_first_strike *LINK;
  1039. {
  1040.   short j;
  1041.   unsigned short w;
  1042.  
  1043.   Jump_in_file(&wpd, 102L);   /* Ga naar TAB-info */
  1044.  
  1045.   LINK->num_of_tabs = 0;
  1046.  
  1047.   for (j = 1; j <= 40; j++) {
  1048.     Rd_word(&wpd, &w);
  1049.     if (w > LINK->WP_sidemargin && w != 0xffffL) {
  1050.       LINK->num_of_tabs++;
  1051.       LINK->tabpos[LINK->num_of_tabs - 1] = w - LINK->WP_sidemargin;
  1052.     }
  1053.   }
  1054.  
  1055.   Jump_in_file(&wpd, 24L);
  1056.  
  1057.   Make_tabelentry_tabset(LINK);
  1058. }
  1059.  
  1060.  
  1061.  
  1062. Local Void Page_number_position(LINK)
  1063. struct LOC_Convert_first_strike *LINK;
  1064. {
  1065.   uchar position_code;
  1066.  
  1067.   Jump_in_file(&wpd, 5L);   /*Skip length of code; always 10*/
  1068.   /* + old information */
  1069.   fread(&position_code, sizeof(uchar), 1, wpd);
  1070.  
  1071.   fprintf(strip, "\\pagenumpos");
  1072.   switch (position_code) {
  1073.  
  1074.   case 0x1:
  1075.     fprintf(strip, "{\\pntl}");
  1076.     break;
  1077.  
  1078.   case 0x2:
  1079.     fprintf(strip, "{\\pntc}");
  1080.     break;
  1081.  
  1082.   case 0x3:
  1083.     fprintf(strip, "{\\pntr}");
  1084.     break;
  1085.  
  1086.   case 0x5:
  1087.     fprintf(strip, "{\\pnbl}");
  1088.     break;
  1089.  
  1090.   case 0x6:
  1091.     fprintf(strip, "{\\pnbc}");
  1092.     break;
  1093.  
  1094.   case 0x7:
  1095.     fprintf(strip, "{\\pnbr}");
  1096.     break;
  1097.  
  1098.   default:
  1099.     fprintf(strip, "{\\pnno}");
  1100.     break;
  1101.   }
  1102.  
  1103.   Jump_in_file(&wpd, 6L);
  1104. }
  1105.  
  1106.  
  1107.  
  1108. Local Void Character(LINK)
  1109. struct LOC_Convert_first_strike *LINK;
  1110. {
  1111.   Char ch[256];
  1112.  
  1113.   short j;
  1114.   uchar chr_code, chr_set, b;
  1115.   boolean found;
  1116.  
  1117. #ifdef DEBUG
  1118.     fprintf(stderr, "Called Character with LINK->by = 0x%x\n",LINK->by);
  1119. #endif
  1120.  
  1121.   if (LINK->open_attr_rij[LINK->depth])
  1122.     Open_all_attr(LINK);
  1123.  
  1124.   switch (LINK->by) {
  1125.  
  1126.   case 0xc4:
  1127. #ifdef DEBUG
  1128.     fprintf(stderr, "Character got 0x%x\n", LINK->by);
  1129. #endif
  1130.     fprintf(stderr, "detected special attr\n");
  1131.     break;
  1132.  
  1133.   case 0xa9:   /* Special_char */
  1134. #ifdef DEBUG
  1135.     fprintf(stderr, "Character got 0x%x\n", LINK->by);
  1136. #endif
  1137.     if (LINK->by == 0xa9)
  1138.       strcpy(ch, "-");
  1139.     else
  1140.       strcpy(ch, "\\ ");
  1141.     break;
  1142.  
  1143.   case 0xc0:   /* Extended_char */
  1144. #ifdef DEBUG
  1145.     fprintf(stderr, "Character got 0x%x\n", LINK->by);
  1146. #endif
  1147.     j = 127;
  1148.     found = false;
  1149.  
  1150.     fread(&chr_code, sizeof(uchar), 1, wpd);
  1151.     fread(&chr_set, sizeof(uchar), 1, wpd);
  1152.  
  1153.     while (j < 511 && !found) {
  1154.       j++;
  1155.       if (chr_code == LINK->char_code[j - 0x80] &&
  1156.       chr_set == LINK->char_set[j - 0x80])
  1157.     found = true;
  1158.     }
  1159.  
  1160.     if (found)
  1161.       strcpy(ch, LINK->ext_lat[j - 0x80]);
  1162.     else
  1163.       strcpy(ch, "\\ ");
  1164.  
  1165.     fread(&b, sizeof(uchar), 1, wpd);
  1166.     break;
  1167.  
  1168.   default:
  1169.     if (LINK->by >= 0x20 && LINK->by <= 0x7f) {
  1170.       /* Normal_char  */
  1171.       strcpy(ch, LINK->lat[LINK->by - 0x20]);
  1172.     }
  1173.  
  1174.     break;
  1175.   }
  1176.  
  1177.   fputs(ch, strip);
  1178.  
  1179. }
  1180.  
  1181.  
  1182.  
  1183. Local Void Return_Page(LINK)
  1184. struct LOC_Convert_first_strike *LINK;
  1185. {
  1186.   switch (LINK->by) {
  1187.  
  1188.   case 0x0a:
  1189.   case 0x8c:   /* Hard return */
  1190.     LINK->line_term = 'R';
  1191.     break;
  1192.  
  1193.   case 0x0d:   /* Soft return */
  1194.     LINK->line_term = 'r';
  1195.     break;
  1196.  
  1197.   case 0xc:   /* Hard page */
  1198.     LINK->line_term = 'P';
  1199.     break;
  1200.  
  1201.   case 0xb:   /* Soft page */
  1202.     LINK->line_term = 'p';
  1203.     break;
  1204.   }
  1205.  
  1206.   putc('\n', strip);
  1207.  
  1208.   Make_tabelentry_envir_extra_end(LINK);
  1209.  
  1210.   if (LINK->indent_end) {
  1211.     LINK->envir = ' ';
  1212.     LINK->indenting = false;
  1213.     LINK->ind_text1 = false;
  1214.     LINK->ind_text2 = false;
  1215.     LINK->ind_leftmargin = 0;
  1216.     LINK->ind_rightmargin = 0;
  1217.  
  1218.     LINK->indent_end = false;
  1219.   } else if (LINK->envir != 'I')
  1220.     LINK->envir = ' ';
  1221.  
  1222.  
  1223.   LINK->char_on_line = false;
  1224.   LINK->nomore_valid_tabs = false;
  1225.  
  1226.   LINK->regelnum++;
  1227.  
  1228.   Make_tabelentry_attr(LINK);
  1229.  
  1230.   LINK->latex_tabpos = 0;
  1231. }
  1232.  
  1233.  
  1234. Local Void Nop80(LINK)
  1235. struct LOC_Convert_first_strike *LINK;
  1236. {
  1237.   /* Om dat het een 1-byte funktie is hoeft er niks overgeslagen */
  1238.   /* te worden.                                                  */
  1239. }
  1240.  
  1241.  
  1242.  
  1243. Local Void NopC0(LINK)
  1244. struct LOC_Convert_first_strike *LINK;
  1245. {
  1246. #ifdef DEBUG
  1247.     fprintf(stderr, "NopC0 called with LINK->by = 0x%x\n", LINK->by);
  1248. #endif
  1249.   if (LINK->by == 0xc0)
  1250.     Jump_in_file(&wpd, 3L);
  1251.   if (LINK->by == 0xc1)
  1252.     Jump_in_file(&wpd, 8L);
  1253.   if (LINK->by == 0xc2)
  1254.     Jump_in_file(&wpd, 10L);
  1255.   if (LINK->by == 0xc3)
  1256.     Jump_in_file(&wpd, 2L);
  1257.   if (LINK->by == 0xc4)
  1258.     Jump_in_file(&wpd, 2L);
  1259.   if (LINK->by == 0xc5)
  1260.     Jump_in_file(&wpd, 4L);
  1261.   if (LINK->by == 0xc6)
  1262.     Jump_in_file(&wpd, 5L);
  1263.   if (LINK->by == 0xc7)
  1264.     Jump_in_file(&wpd, 6L);
  1265. }
  1266.  
  1267.  
  1268.  
  1269. Local Void NopD0(already_read_subfunc_code, LINK)
  1270. boolean already_read_subfunc_code;
  1271. struct LOC_Convert_first_strike *LINK;
  1272. {
  1273.   uchar b;
  1274.   unsigned short w;
  1275.  
  1276.   if (!already_read_subfunc_code)   /* Lees subfunctioncode */
  1277.     fread(&b, sizeof(uchar), 1, wpd);
  1278.  
  1279.   Rd_word(&wpd, &w);   /* Lees lengte 'die nog volgt ' */
  1280.   fseek(wpd, (ftell(wpd) / sizeof(uchar) + w) * sizeof(uchar), 0);
  1281. }
  1282.  
  1283.  
  1284.  
  1285. Local Void Overstrike(LINK)
  1286. struct LOC_Convert_first_strike *LINK;
  1287. {
  1288.   boolean first_char_os;
  1289.  
  1290.   unsigned short char_width_os, len_of_code;
  1291.   long end_of_code;
  1292.  
  1293. #ifdef DEBUG
  1294.     fprintf(stderr, "Called Overstrike\n");
  1295. #endif
  1296.  
  1297.   Rd_word(&wpd, &len_of_code);   /* Lees lengte */
  1298.   end_of_code = ftell(wpd) / sizeof(uchar) + len_of_code - 4;
  1299.  
  1300.   Rd_word(&wpd, &char_width_os);
  1301.  
  1302.   first_char_os = true;
  1303.  
  1304.   while (ftell(wpd) / sizeof(uchar) < end_of_code) {
  1305.     fread(&LINK->by, sizeof(uchar), 1, wpd);
  1306.  
  1307.  
  1308.     if (LINK->by >= 0x20 && LINK->by <= 0x7f || LINK->by == 0xa9 ||
  1309.     LINK->by == 0xc0 || LINK->by == 0xc4) {
  1310. #ifdef DEBUG
  1311.     fprintf(stderr, "Overstrike got 0x%x\n", LINK->by);
  1312. #endif
  1313.       if (first_char_os) {
  1314.     Character(LINK);
  1315.     first_char_os = false;
  1316.       } else {
  1317.     fprintf(strip, "\\llap{");
  1318.     Character(LINK);
  1319.     putc('}', strip);
  1320.       }
  1321.       continue;
  1322.     }
  1323.  
  1324.     if (LINK->by <= 0xbf)
  1325.       Nop80(LINK);
  1326.     else if (LINK->by >= 0xc0 && LINK->by <= 0xcf)
  1327.       NopC0(LINK);
  1328.     else if (LINK->by >= 0xd0 && LINK->by <= 0xfe)
  1329.       NopD0(false, LINK);
  1330.   }
  1331.  
  1332.   Jump_in_file(&wpd, 4L);
  1333.  
  1334. }
  1335.  
  1336.  
  1337.  
  1338. Local Void Footnote(LINK)
  1339. struct LOC_Convert_first_strike *LINK;
  1340. {
  1341.   uchar flags, num_of_pages;
  1342.  
  1343.   unsigned short fn_num, len_of_code;
  1344.   long end_of_code;
  1345.  
  1346.   Rd_word(&wpd, &len_of_code);   /* Lees lengte */
  1347.   end_of_code = ftell(wpd) / sizeof(uchar) + len_of_code - 4;
  1348.  
  1349.   fread(&flags, sizeof(uchar), 1, wpd);
  1350.  
  1351.   Rd_word(&wpd, &fn_num);
  1352.  
  1353.   /* Skip all the shit */
  1354.  
  1355.   fread(&num_of_pages, sizeof(uchar), 1, wpd);
  1356.   Jump_in_file(&wpd, (num_of_pages + 1L) * 2 + 9);
  1357.  
  1358.   Close_all_attr(LINK);
  1359.  
  1360.   LINK->depth = 1;
  1361.   Reset_attr_rij(LINK->depth, LINK);
  1362.  
  1363.   fprintf(strip, "\\footnote[%u]{", fn_num);
  1364.  
  1365.   while (ftell(wpd) / sizeof(uchar) < end_of_code) {
  1366.     fread(&LINK->by, sizeof(uchar), 1, wpd);
  1367.  
  1368.     switch (LINK->by) {
  1369.  
  1370.     case 0xa:
  1371.     case 0xc:
  1372.       fprintf(strip, "\\\\ ");
  1373.       break;
  1374.  
  1375.     case 0xb:
  1376.     case 0xd:
  1377.       putc(' ', strip);
  1378.       break;
  1379.  
  1380.     case 0xc3:
  1381.       Attr_ON(LINK);
  1382.       break;
  1383.  
  1384.     case 0xc4:
  1385.       Attr_OFF(LINK);
  1386.       break;
  1387.  
  1388.     default:
  1389. #ifdef DEBUG
  1390.     fprintf(stderr, "defaulting\n");
  1391. #endif
  1392.       if (LINK->by >= 0x20 && LINK->by <= 0x7f || LINK->by == 0xa9 ||
  1393.       LINK->by == 0xc0 || LINK->by == 0xc4)
  1394.     Character(LINK);
  1395.       else if (LINK->by <= 0xbf)
  1396.     Nop80(LINK);
  1397.       else if (LINK->by >= 0xc0 && LINK->by <= 0xcf)
  1398.     NopC0(LINK);
  1399.       else if (LINK->by >= 0xd0 && LINK->by <= 0xfe)
  1400.     NopD0(false, LINK);
  1401.  
  1402.       break;
  1403.     }
  1404.  
  1405.   }
  1406.  
  1407.   Close_all_attr(LINK);   /* Echt nodig ? */
  1408.   putc('}', strip);
  1409.  
  1410.   Jump_in_file(&wpd, 4L);
  1411.  
  1412.   LINK->depth = 0;
  1413.   Open_all_attr(LINK);
  1414.  
  1415. }
  1416.  
  1417.  
  1418.  
  1419. Local Void Header_Footer(LINK)
  1420. struct LOC_Convert_first_strike *LINK;
  1421. {
  1422.   uchar subfunc, occurance;
  1423.   unsigned short len_of_code;
  1424.   long end_of_code;
  1425.  
  1426.   boolean hf_left, hf_center, hf_right;
  1427.  
  1428.   short j;
  1429.  
  1430.   fread(&subfunc, sizeof(uchar), 1, wpd);
  1431.   Rd_word(&wpd, &len_of_code);
  1432.  
  1433.   if (len_of_code <= 22) {
  1434.     Jump_in_file(&wpd, (long)len_of_code);
  1435.     return;
  1436.   }
  1437.  
  1438.  
  1439.   end_of_code = ftell(wpd) / sizeof(uchar) + len_of_code - 4;
  1440.  
  1441.   Jump_in_file(&wpd, 7L);
  1442.  
  1443.   fread(&occurance, sizeof(uchar), 1, wpd);
  1444.  
  1445.   Jump_in_file(&wpd, 10L);
  1446.  
  1447.   Close_all_attr(LINK);
  1448.   LINK->depth = 1;
  1449.  
  1450.   /* Geen schone attr._lei; Kopieer attributen uit Niveau 0;  Fout in WP 5.0 ? */
  1451.  
  1452.   for (j = 0; j <= 15; j++)
  1453.     LINK->attr_rij[1][j] = LINK->attr_rij[0][j];
  1454.  
  1455.   LINK->leegptr[1] = LINK->leegptr[0];
  1456.   LINK->openptr[1] = LINK->openptr[0];
  1457.  
  1458.   switch (subfunc) {
  1459.  
  1460.   case 0:
  1461.   case 1:
  1462.     fprintf(strip, "\\headtext");
  1463.     break;
  1464.  
  1465.   case 2:
  1466.   case 3:
  1467.     fprintf(strip, "\\foottext");
  1468.     break;
  1469.   }
  1470.  
  1471.   switch (occurance) {
  1472.  
  1473.   case 0:
  1474.     fprintf(strip, "{\\neverpages}{");
  1475.     break;
  1476.  
  1477.   case 1:
  1478.     fprintf(strip, "{\\allpages}{");
  1479.     break;
  1480.  
  1481.   case 2:
  1482.     fprintf(strip, "{\\oddpages}{");
  1483.     break;
  1484.  
  1485.   case 3:
  1486.     fprintf(strip, "{\\evenpages}{");
  1487.     break;
  1488.   }
  1489.  
  1490.   Open_all_attr(LINK);
  1491.   hf_left = true;   /* Beginnen met de linkerkant */
  1492.   hf_center = false;
  1493.   hf_right = false;
  1494.  
  1495.   while (ftell(wpd) / sizeof(uchar) < end_of_code) {
  1496.     fread(&LINK->by, sizeof(uchar), 1, wpd);
  1497.  
  1498.     switch (LINK->by) {
  1499.  
  1500.     case 0xc1:
  1501.       fread(&LINK->by, sizeof(uchar), 1, wpd);
  1502.       LINK->by &= 0xe0;
  1503.       Jump_in_file(&wpd, 7L);
  1504.  
  1505.       if (LINK->by == 0xe0) {
  1506.     if (hf_left) {
  1507.       Close_all_attr(LINK);
  1508.       fprintf(strip, "}{");
  1509.       Open_all_attr(LINK);
  1510.  
  1511.       hf_left = false;
  1512.       hf_center = true;
  1513.     }
  1514.       }
  1515.  
  1516.       if (LINK->by == 0x60) {
  1517.     if (hf_left) {
  1518.       Close_all_attr(LINK);
  1519.       fprintf(strip, "}{}{");
  1520.       Open_all_attr(LINK);
  1521.  
  1522.       hf_left = false;
  1523.       hf_right = true;
  1524.     }
  1525.  
  1526.     if (hf_center) {
  1527.       Close_all_attr(LINK);
  1528.       fprintf(strip, "}{");
  1529.       Open_all_attr(LINK);
  1530.  
  1531.       hf_center = false;
  1532.       hf_right = true;
  1533.     }
  1534.       }
  1535.       break;
  1536.  
  1537.     case 0xc3:
  1538.       Attr_ON(LINK);
  1539.       break;
  1540.  
  1541. #ifndef DEBUG
  1542.     case 0xc4:
  1543.       Attr_OFF(LINK);
  1544.       break;
  1545. #endif
  1546.  
  1547.     default:
  1548.       if (LINK->by >= 0x20 && LINK->by <= 0x7f || LINK->by == 0xa9 ||
  1549.       LINK->by == 0xc0 || LINK->by == 0xc4)
  1550.     Character(LINK);
  1551.       else if (LINK->by <= 0xbf)
  1552.     Nop80(LINK);
  1553.       else if (LINK->by >= 0xc0 && LINK->by <= 0xcf)
  1554.     NopC0(LINK);
  1555.       else if (LINK->by >= 0xd0 && LINK->by <= 0xfe)
  1556.     NopD0(false, LINK);
  1557.  
  1558.  
  1559.       break;
  1560.     }
  1561.   }
  1562.  
  1563.   Close_all_attr(LINK);   /* Echt nodig ? */
  1564.  
  1565.   Jump_in_file(&wpd, 4L);
  1566.  
  1567.   if (hf_left)
  1568.     fprintf(strip, "}{}{}");
  1569.   if (hf_center)
  1570.     fprintf(strip, "}{}");
  1571.   if (hf_right)
  1572.     putc('}', strip);
  1573.  
  1574.   LINK->depth = 0;
  1575.   Open_all_attr(LINK);
  1576.  
  1577.  
  1578.  
  1579. }
  1580.  
  1581.  
  1582. /*---SLAG1----*/
  1583.  
  1584. Static Void Convert_first_strike()
  1585. {
  1586.   /* Dit is de komplete procedure van de eerste slag met zijn eigen proc.'s. */
  1587.   struct LOC_Convert_first_strike V;
  1588.  
  1589.   short convperc;
  1590.  
  1591.   long srtdocpos, fsize;
  1592.  
  1593.  
  1594.   Table_Init(&V);
  1595.   Ext_chr_init(&V);
  1596.  
  1597.   Reset_attr_rij(0, &V);
  1598.   Reset_attr_rij(1, &V);
  1599.   V.depth = 0;
  1600.  
  1601.   WP_Default(&V);
  1602.  
  1603.   V.latex_tabpos = 0;
  1604.   V.right_tab = false;
  1605.   V.align_tab = false;
  1606.   V.center_tab = false;
  1607.  
  1608.   V.indenting = false;
  1609.   V.indent_end = false;
  1610.   V.ind_text1 = false;
  1611.   V.ind_text2 = false;
  1612.   V.ind_leftmargin = 0;
  1613.   V.ind_rightmargin = 0;
  1614.  
  1615.   V.envir = ' ';
  1616.  
  1617.   V.nomore_valid_tabs = false;
  1618.  
  1619.   printf("First strike :\n");
  1620. #ifndef sun
  1621.   printf("Converting-percentage :     ");
  1622. #endif
  1623.  
  1624.   srtdocpos = ftell(wpd) / sizeof(uchar);
  1625.   fsize = P_maxpos(wpd) / sizeof(uchar) + 1;
  1626.  
  1627.   V.regelnum = 0;
  1628.  
  1629.   Make_tabelentry_attr(&V);   /* attribuut instelling */
  1630.  
  1631.   Make_tabelentry_tabset(&V);   /* Geef de defaulttabinstelling door */
  1632.   /* aan de 2e slag */
  1633.  
  1634.   while (ftell(wpd) / sizeof(uchar) < fsize-2) {
  1635. #ifndef sun
  1636.     convperc = (long)floor((double)(ftell(wpd) / sizeof(uchar) - srtdocpos) /
  1637.                (fsize - srtdocpos) * 100 + 0.5);
  1638.     printf("\b\b\b\b%3d%%", convperc);
  1639. #endif
  1640.  
  1641.     fread(&V.by, sizeof(uchar), 1, wpd);
  1642.  
  1643.     switch (V.by) {
  1644.  
  1645.     case 0xa:
  1646.     case 0xd:
  1647.     case 0xb:
  1648.     case 0xc:
  1649.     case 0x8c:
  1650.       Return_Page(&V);
  1651.       break;
  1652.  
  1653.     case 0xc1:
  1654.       fread(&V.by, sizeof(uchar), 1, wpd);
  1655.       V.by &= 0xe8;
  1656.  
  1657.       switch (V.by) {
  1658.  
  1659.       case 0:
  1660.       case 0xc8:
  1661.       case 0x48:
  1662.       case 0x40:
  1663.     Tab(&V);
  1664.     break;
  1665.  
  1666.       case 0x60:
  1667.     Flush_right_tab(&V);
  1668.     break;
  1669.  
  1670.       case 0xe0:
  1671.     Center(&V);
  1672.     break;
  1673.  
  1674.       default:
  1675.     Jump_in_file(&wpd, 7L);
  1676.     break;
  1677.       }
  1678.       break;
  1679.  
  1680.     case 0x81:
  1681.     case 0x82:
  1682.       Make_tabelentry_rightjustification(&V);
  1683.       break;
  1684.  
  1685.     case 0x83:
  1686.       End_Align(&V);
  1687.       break;
  1688.  
  1689.     case 0xc3:
  1690.       Attr_ON(&V);
  1691.       break;
  1692.  
  1693.     case 0xc4:
  1694.       Attr_OFF(&V);
  1695.       break;
  1696.  
  1697.     case 0xc2:
  1698.       Indent(&V);
  1699.       break;
  1700.  
  1701.     case 0xc6:
  1702.       End_of_indent(&V);
  1703.       break;
  1704.  
  1705.     case 0xc5:
  1706.     case 0xc7:
  1707.       NopC0(&V);
  1708.       break;
  1709.  
  1710.     case 0xd0:
  1711.       fread(&V.by, sizeof(uchar), 1, wpd);
  1712.       switch (V.by) {
  1713.  
  1714.       case 0x4:
  1715.     Tabset(&V);
  1716.     break;
  1717.  
  1718.       case 0x8:
  1719.     Page_number_position(&V);
  1720.     break;
  1721.  
  1722.       default:
  1723.     NopD0(true, &V);
  1724.     break;
  1725.       }
  1726.       break;
  1727.  
  1728.     case 0xd5:
  1729.       Header_Footer(&V);
  1730.       break;
  1731.  
  1732.     case 0xd6:
  1733.       fread(&V.by, sizeof(uchar), 1, wpd);
  1734.       switch (V.by) {
  1735.  
  1736.       case 0:
  1737.     Footnote(&V);
  1738.     break;
  1739.  
  1740.       default:
  1741.     NopD0(true, &V);
  1742.     break;
  1743.       }
  1744.       break;
  1745.  
  1746.     case 0xd8:
  1747.       fread(&V.by, sizeof(uchar), 1, wpd);
  1748.       switch (V.by) {
  1749.  
  1750.       case 0x2:
  1751.     Overstrike(&V);
  1752.     break;
  1753.  
  1754.       default:
  1755.     NopD0(true, &V);
  1756.     break;
  1757.       }
  1758.       break;
  1759.  
  1760.     default:
  1761.       if (V.by >= 0x20 && V.by <= 0x7f || V.by == 0xa9 
  1762.     || V.by == 0xc0 || V.by == 0xc4) {
  1763.     V.char_on_line = true;   /*Er (al) is een karakter op deze regel */
  1764.     if (V.indenting) {   /*Als er is ingeprongen er na een stuk */
  1765.       if (V.ind_text1)   /*tekst is weer ingesprongen (ind_text1) */
  1766.         V.ind_text2 = true;
  1767.     }
  1768.     /*dan hoort dit char bij het ind_txt-blok */
  1769.  
  1770.     Character(&V);
  1771.       } else if (V.by <= 0x1f || V.by >= 0x80 && V.by <= 0xbf)
  1772.     Nop80(&V);
  1773.       else if (V.by >= 0xd0 && V.by <= 0xff)
  1774.     NopD0(false, &V);
  1775.  
  1776.       break;
  1777.     }
  1778.   }
  1779.  
  1780.   putchar('\n');
  1781.   Make_tabelentry_envir_extra_end(&V);
  1782.  
  1783.   num_of_lines_stripfile = V.regelnum;
  1784.  
  1785.  
  1786.  
  1787.  
  1788. }
  1789.  
  1790.  
  1791. /* Local variables for Convert_second_strike: */
  1792. struct LOC_Convert_second_strike {
  1793.   boolean just_envir_closed;
  1794.  
  1795.   short num_of_tabs;
  1796.   unsigned short tabpos[40];
  1797.  
  1798.   short tabent_num_of_tabs[3];
  1799.   unsigned short tabent_tabpos[3][40];
  1800.  
  1801.   unsigned short ind_leftmargin[3], ind_rightmargin[3];
  1802.   uchar ind_label[3];
  1803.  
  1804.   short pre, cur, next;
  1805.  
  1806.   Char envir[3], line_term[3];
  1807.   boolean new_tabset[3];
  1808.   boolean new_rightjust;
  1809.   boolean new_tabent_rightjust[3], tabent_rightjust[3];
  1810.  
  1811.   short num_of_attr[3];
  1812.   uchar attr_BOL[3][0x11];
  1813.   boolean attr_closed;
  1814. } ;
  1815.  
  1816.  
  1817.  
  1818. Local Void Read_tabelentry(n, LINK)
  1819. short n;
  1820. struct LOC_Convert_second_strike *LINK;
  1821. {
  1822.   unsigned short w;
  1823.   uchar b;
  1824.   short j, FORLIM;
  1825.  
  1826.   /* Begin met een schone lei die dan door deze procedure verder wordt */
  1827.   /* opgevuld. */
  1828.  
  1829.   LINK->envir[n] = ' ';
  1830.   LINK->new_tabset[n] = false;
  1831.   LINK->new_tabent_rightjust[n] = false;
  1832.  
  1833.   LINK->num_of_attr[n] = 0;
  1834.   for (j = 1; j <= 16; j++)
  1835.     LINK->attr_BOL[n][j] = 0;
  1836.  
  1837.   if (ftell(tabel) / sizeof(uchar) > P_maxpos(tabel) / sizeof(uchar))
  1838.     return;
  1839.  
  1840.  
  1841.   /* Er is geen volgende tabelentry dus ook geen volgende regel */
  1842.   /* De tabelentry is 'schoon'.                                 */
  1843.   /* Zodat het document 'schoon' wordt afgesloten.              */
  1844.  
  1845.   fread(&b, sizeof(uchar), 1, tabel);
  1846.   LINK->num_of_attr[n] = b;
  1847.   FORLIM = LINK->num_of_attr[n];
  1848.   for (j = 1; j <= FORLIM; j++)
  1849.     fread(&LINK->attr_BOL[n][j], sizeof(uchar), 1, tabel);
  1850.  
  1851.   b = 0;
  1852.   while ((b != 0xff) && !feof(tabel)) {
  1853.     fread(&b, sizeof(uchar), 1, tabel);
  1854.  
  1855.     switch (b) {   /*Case*/
  1856.  
  1857.     case 'C':
  1858.       LINK->envir[n] = 'C';
  1859.       break;
  1860.  
  1861.     case 'T':
  1862.       LINK->envir[n] = 'T';
  1863.       break;
  1864.  
  1865.     case 'I':
  1866.       LINK->envir[n] = 'I';
  1867.       Rd_word(&tabel, &LINK->ind_leftmargin[n]);
  1868.       Rd_word(&tabel, &LINK->ind_rightmargin[n]);
  1869.       fread(&LINK->ind_label[n], sizeof(uchar), 1, tabel);
  1870.       break;
  1871.  
  1872.     case 'S':
  1873.       LINK->new_tabset[n] = true;
  1874.       fread(&b, sizeof(uchar), 1, tabel);
  1875.       LINK->tabent_num_of_tabs[n] = b;
  1876.  
  1877.       FORLIM = LINK->tabent_num_of_tabs[n];
  1878.       for (j = 0; j < FORLIM; j++) {
  1879.     Rd_word(&tabel, &w);
  1880.     LINK->tabent_tabpos[n][j] = w;
  1881.       }
  1882.       break;
  1883.  
  1884.     case 'U':
  1885.       LINK->new_tabent_rightjust[n] = true;
  1886.       fread(&b, sizeof(uchar), 1, tabel);
  1887.       if (b == 0)
  1888.     LINK->tabent_rightjust[n] = false;
  1889.       else
  1890.     LINK->tabent_rightjust[n] = true;
  1891.       break;
  1892.  
  1893.     case 'R':
  1894.     case 'r':
  1895.     case 'P':
  1896.     case 'p':
  1897.       LINK->line_term[n] = b;
  1898.       break;
  1899.  
  1900.     }
  1901.   }
  1902. }
  1903.  
  1904.  
  1905.  
  1906. Local Void Open_all_attr_BOL(LINK)
  1907. struct LOC_Convert_second_strike *LINK;
  1908. {
  1909.   /* -- Open alle commando's door de Attributen-rij af te lopen -- */
  1910.   short j, FORLIM;
  1911.  
  1912.   FORLIM = LINK->num_of_attr[LINK->cur];
  1913.   for (j = 0x1; j <= FORLIM; j++)
  1914.     fputs(open_com[LINK->attr_BOL[LINK->cur][j]], latex);
  1915.  
  1916.   LINK->attr_closed = false;
  1917. }
  1918.  
  1919.  
  1920. Local Void Close_all_attr_BOL(LINK)
  1921. struct LOC_Convert_second_strike *LINK;
  1922. {
  1923.   /* -- Sluit alle commando's door de Attributen-rij af te lopen -- */
  1924.   short j;
  1925.  
  1926.   for (j = LINK->num_of_attr[LINK->cur]; j >= 0x1; j--)
  1927.     fputs(close_com[LINK->attr_BOL[LINK->cur][j]], latex);
  1928.  
  1929.   LINK->attr_closed = true;
  1930. }
  1931.  
  1932.  
  1933.  
  1934. Local Void Open_all_attr_EOL(LINK)
  1935. struct LOC_Convert_second_strike *LINK;
  1936. {
  1937.   /* -- Open alle commando's door de Attributen-rij af te lopen -- */
  1938.   short j, FORLIM;
  1939.  
  1940.   FORLIM = LINK->num_of_attr[LINK->next];
  1941.   for (j = 0x1; j <= FORLIM; j++)
  1942.     fputs(open_com[LINK->attr_BOL[LINK->next][j]], latex);
  1943.  
  1944.   LINK->attr_closed = false;
  1945. }
  1946.  
  1947.  
  1948.  
  1949. Local Void Close_all_attr_EOL(LINK)
  1950. struct LOC_Convert_second_strike *LINK;
  1951. {
  1952.   /* -- Sluit alle commando's door de Attributen-rij af te lopen -- */
  1953.   short j;
  1954.  
  1955.   for (j = LINK->num_of_attr[LINK->next]; j >= 0x1; j--)
  1956.     fputs(close_com[LINK->attr_BOL[LINK->next][j]], latex);
  1957.  
  1958.   LINK->attr_closed = true;
  1959. }
  1960.  
  1961.  
  1962.  
  1963. Local Void Latex_head(LINK)
  1964. struct LOC_Convert_second_strike *LINK;
  1965. {
  1966.   /* -- Maak het de standard-heading voor een latex-file aan -- */
  1967.   fprintf(latex, "\\documentstyle[11pt,wp2latex]{report}\n");
  1968.   fprintf(latex, "\\begin{document}\n");
  1969. }
  1970.  
  1971.  
  1972.  
  1973. Local Void Latex_foot(LINK)
  1974. struct LOC_Convert_second_strike *LINK;
  1975. {
  1976.   /* -- Sluit de latex-file op de juiste wijze af -- */
  1977.   fprintf(latex, "\\end{document}\n");
  1978. }
  1979.  
  1980.  
  1981.  
  1982. Local Void Latex_tabset(LINK)
  1983. struct LOC_Convert_second_strike *LINK;
  1984. {
  1985.   short atpr, j;
  1986.   double l, ol;
  1987.   short FORLIM;
  1988.  
  1989.   atpr = 0;   /* Huiding aantal tabs per regel */
  1990.   ol = 0.0;
  1991.   FORLIM = LINK->num_of_tabs;
  1992.   for (j = 0; j < FORLIM; j++) {
  1993.     l = LINK->tabpos[j] / 1200.0 * 2.54;
  1994.     fprintf(latex, "\\hspace{%3.2fcm}\\=", l - ol);
  1995.     atpr++;
  1996.     if (atpr >= 4) {
  1997.       fprintf(latex, "%%\n");
  1998.       atpr = 0;
  1999.     }
  2000.     ol = l;
  2001.   }
  2002.   fprintf(latex, "\\kill\n");
  2003. }
  2004.  
  2005.  
  2006.  
  2007. Local boolean Change_envir_BOL(LINK)
  2008. struct LOC_Convert_second_strike *LINK;
  2009. {
  2010.   boolean hulp;
  2011.  
  2012.   hulp = false;
  2013.  
  2014.   hulp = (LINK->envir[LINK->cur] == 'C' && LINK->envir[LINK->pre] != 'C' ||
  2015.       hulp);
  2016.   hulp = (LINK->envir[LINK->cur] == 'T' && LINK->envir[LINK->pre] != 'T' ||
  2017.       hulp);
  2018.   hulp = (LINK->envir[LINK->cur] == 'I' && LINK->envir[LINK->pre] != 'I' ||
  2019.       hulp);
  2020.  
  2021.   return hulp;
  2022. }
  2023.  
  2024.  
  2025.  
  2026. Local boolean Change_envir_EOL(LINK)
  2027. struct LOC_Convert_second_strike *LINK;
  2028. {
  2029.   boolean hulp;
  2030.  
  2031.   hulp = false;
  2032.  
  2033.   hulp = (((LINK->envir[LINK->next] == 'C') ^ (LINK->envir[LINK->cur] == 'C')) ||
  2034.       hulp);
  2035.   hulp = (((LINK->envir[LINK->next] == 'T') ^ (LINK->envir[LINK->cur] == 'T')) ||
  2036.       hulp);
  2037.   hulp = (((LINK->envir[LINK->next] == 'I') ^ (LINK->envir[LINK->cur] == 'I')) ||
  2038.       hulp);
  2039.  
  2040.   return hulp;
  2041. }
  2042.  
  2043.  
  2044.  
  2045.  
  2046. Local Void Open_environment(LINK)
  2047. struct LOC_Convert_second_strike *LINK;
  2048. {
  2049.   if (!Change_envir_BOL(LINK)) {   /* andere environment ? */
  2050.     if (LINK->new_tabset[LINK->cur] && LINK->envir[LINK->cur] == 'T')
  2051.       Latex_tabset(LINK);
  2052.     return;
  2053.   }
  2054.  
  2055.  
  2056.   if (!LINK->attr_closed)
  2057.     Close_all_attr_BOL(LINK);
  2058.  
  2059.   switch (LINK->envir[LINK->cur]) {
  2060.  
  2061.   case 'C':
  2062.     fprintf(latex, "\\begin{center}\n");
  2063.     break;
  2064.  
  2065.   case 'T':
  2066.     fprintf(latex, "\\begin{tabbing}\n");
  2067.     Latex_tabset(LINK);
  2068.     break;
  2069.  
  2070.   case 'I':
  2071.     fprintf(latex, "\\begin{indenting}");
  2072.     fprintf(latex, "{%3.2fcm}",
  2073.         LINK->ind_leftmargin[LINK->cur] / 1200.0 * 2.54);
  2074.     fprintf(latex, "{%3.2fcm}",
  2075.         LINK->ind_rightmargin[LINK->cur] / 1200.0 * 2.54);
  2076.     if (LINK->ind_label[LINK->cur] == 1) {
  2077.       fprintf(latex, "%%\n");
  2078.       putc('{', latex);
  2079.     } else
  2080.       fprintf(latex, "{}\n");
  2081.     break;
  2082.   }
  2083.  
  2084. }
  2085.  
  2086.  
  2087.  
  2088. Local Void Close_environment(LINK)
  2089. struct LOC_Convert_second_strike *LINK;
  2090. {
  2091.   switch (LINK->envir[LINK->cur]) {
  2092.  
  2093.   case 'C':
  2094.     fprintf(latex, "\\end{center}\n");
  2095.     break;
  2096.  
  2097.   case 'T':
  2098.     fprintf(latex, "\\end{tabbing}\n");
  2099.     break;
  2100.  
  2101.   case 'I':
  2102.     fprintf(latex, "\\end{indenting}\n");
  2103.     break;
  2104.   }
  2105.  
  2106.   LINK->just_envir_closed = true;
  2107.  
  2108. }
  2109.  
  2110.  
  2111.  
  2112. Local Void Update_global_information(LINK)
  2113. struct LOC_Convert_second_strike *LINK;
  2114. {
  2115.   short j, FORLIM;
  2116.  
  2117.   if (LINK->new_tabset[LINK->cur]) {
  2118.     LINK->num_of_tabs = LINK->tabent_num_of_tabs[LINK->cur];
  2119.     FORLIM = LINK->num_of_tabs;
  2120.     for (j = 0; j < FORLIM; j++)
  2121.       LINK->tabpos[j] = LINK->tabent_tabpos[LINK->cur][j];
  2122.   }
  2123.  
  2124.   if (LINK->new_tabent_rightjust[LINK->cur])
  2125.     LINK->new_rightjust = LINK->tabent_rightjust[LINK->cur];
  2126.  
  2127. }
  2128.  
  2129.  
  2130. Local Void Change_tabelentry(LINK)
  2131. struct LOC_Convert_second_strike *LINK;
  2132. {
  2133.   short help;
  2134.  
  2135.   help = LINK->pre;
  2136.   LINK->pre = LINK->cur;
  2137.   LINK->cur = LINK->next;
  2138.   LINK->next = help;
  2139.   Read_tabelentry(LINK->next, LINK);
  2140. }
  2141.  
  2142.  
  2143. /*---SLAG2---*/
  2144.  
  2145. Static Void Convert_second_strike()
  2146. {
  2147.   struct LOC_Convert_second_strike V;
  2148.   unsigned short regelnum;
  2149.   short convperc;
  2150.  
  2151.   boolean underline;
  2152.  
  2153.   short i;
  2154.  
  2155.   Char regel[256], hulp_regel[256];
  2156.   short len_reg;
  2157.  
  2158.   boolean rightjust;
  2159.   Char STR3[256];
  2160.   Char *TEMP;
  2161.  
  2162.  
  2163.   V.pre = 0;
  2164.   V.cur = 1;
  2165.   V.next = 2;
  2166.  
  2167.   V.envir[V.pre] = ' ';
  2168.   V.new_tabset[V.pre] = false;
  2169.  
  2170.   V.just_envir_closed = true;
  2171.   V.attr_closed = false;
  2172.  
  2173.   rightjust = true;
  2174.   V.new_rightjust = true;
  2175.   for (i = 0; i <= 2; i++) {
  2176.     V.new_tabent_rightjust[i] = false;
  2177.     V.tabent_rightjust[i] = false;
  2178.   }
  2179.  
  2180.   Read_tabelentry(V.cur, &V);
  2181.   Read_tabelentry(V.next, &V);
  2182.  
  2183.   regelnum = 1;
  2184.  
  2185.   printf("\nSecond strike :\n");
  2186. #ifndef sun
  2187.   printf("Converting-percentage :     ");
  2188. #endif
  2189.  
  2190.  
  2191.  
  2192.   Latex_head(&V);
  2193.  
  2194.   while (!P_eof(strip)) {
  2195.     Update_global_information(&V);
  2196.  
  2197. #ifndef sun
  2198.     convperc = (long)floor(regelnum * 100.0 / num_of_lines_stripfile + 0.5);
  2199.     if (convperc > 100)
  2200.       convperc = 100;
  2201.     printf("\b\b\b\b%3d%%", convperc);
  2202. #endif
  2203.  
  2204.     fgets(regel, 256, strip);
  2205.     TEMP = (char *)strchr(regel, '\n');
  2206.     if (TEMP != NULL)
  2207.       *TEMP = 0;
  2208.  
  2209.     /* Werk eventueel de regel bij d.m.v. een hulp regel. */
  2210.  
  2211.     strcpy(hulp_regel, regel);
  2212.     len_reg = strlen(hulp_regel);
  2213.  
  2214.     /* Meerdere spaties achter elkaar vervangen door harde spaties. */
  2215.  
  2216.     for (i = 1; i < len_reg; i++) {
  2217.       if (regel[i - 1] == ' ' && regel[i] == ' ')
  2218.     hulp_regel[i] = '~';
  2219.     }
  2220.  
  2221.     /* Zoek naar een illegaal argument en zet hier accolades voor. */
  2222.  
  2223.     if (len_reg >= 1 && hulp_regel[0] == '[' ||
  2224.     len_reg >= 2 && hulp_regel[0] == ' ' && hulp_regel[1] == '[')
  2225.       sprintf(hulp_regel, "{}%s", strcpy(STR3, hulp_regel));
  2226.  
  2227.     /* De regel is verwerkt. */
  2228.  
  2229.     strcpy(regel, hulp_regel);
  2230.     len_reg = strlen(regel);
  2231.  
  2232.     if (V.new_rightjust ^ rightjust) {
  2233.       rightjust = V.new_rightjust;
  2234.       if (rightjust)
  2235.     fprintf(latex, "\\justified\n");
  2236.       else
  2237.     fprintf(latex, "\\raggedright\n");
  2238.     }
  2239.  
  2240.     Open_environment(&V);
  2241.  
  2242.     if (len_reg > 0) {
  2243.       if (V.attr_closed)
  2244.     Open_all_attr_BOL(&V);
  2245.  
  2246.       fputs(regel, latex);
  2247.  
  2248.       V.just_envir_closed = false;
  2249.     }
  2250.  
  2251.     switch (V.line_term[V.cur]) {   /*Case*/
  2252.  
  2253.     case 'r':
  2254.     case 'p':
  2255.       fputc('\n', latex);
  2256.       if (Change_envir_EOL(&V)) {
  2257.          if (!V.attr_closed) {
  2258.            Close_all_attr_EOL(&V);
  2259.          }
  2260.  
  2261.          Close_environment(&V);
  2262.       }
  2263.       break;
  2264.  
  2265.     case 'R':
  2266.       if (V.envir[V.cur] == 'I') {
  2267.     if (!V.attr_closed)
  2268.       Close_all_attr_EOL(&V);
  2269.  
  2270.     putc('\n', latex);
  2271.     Close_environment(&V);
  2272.     V.envir[V.cur] = ' ';
  2273.       } else {
  2274.     underline = false;
  2275.     for (i = 0x1; i <= 0x10; i++)
  2276.       underline = (underline || V.attr_BOL[V.next][i] == 0xb ||
  2277.                V.attr_BOL[V.next][i] == 0xe);
  2278.  
  2279.     if (underline && !V.attr_closed)
  2280.       Close_all_attr_EOL(&V);
  2281.  
  2282.     /* Elke Indent-environment moet na een harde Return*/
  2283.     /* Afgesloten worden.*/
  2284.  
  2285.  
  2286.     if (Change_envir_EOL(&V)) {
  2287.       if (V.just_envir_closed)
  2288.         fprintf(latex, "\\nwln\n");
  2289.       else
  2290.         putc('\n', latex);
  2291.  
  2292.       if (!V.attr_closed)
  2293.         Close_all_attr_EOL(&V);
  2294.  
  2295.       Close_environment(&V);
  2296.     } else {
  2297.       if (V.just_envir_closed)
  2298.         fprintf(latex, "\\nwln\n");
  2299.       else
  2300.         fprintf(latex, "\\\\\n");
  2301.     }
  2302.       }
  2303.  
  2304.       break;
  2305.  
  2306.  
  2307.     case 'P':
  2308.       if (!V.attr_closed)
  2309.     Close_all_attr_EOL(&V);
  2310.  
  2311.       putc('\n', latex);
  2312.       Close_environment(&V);
  2313.       fprintf(latex, "\\newpage\n");
  2314.       V.envir[V.cur] = ' ';
  2315.       break;
  2316.  
  2317.     }
  2318.  
  2319.  
  2320.  
  2321.     Change_tabelentry(&V);
  2322.  
  2323.     regelnum++;
  2324.   }
  2325.  
  2326.   Latex_foot(&V);
  2327.   putchar('\n');
  2328. }
  2329.  
  2330. /*---HOOFDPROG---*/
  2331.  
  2332. main(argc, argv)
  2333. int argc;
  2334. Char *argv[];
  2335. {
  2336.  
  2337.   PASCAL_MAIN(argc, argv);
  2338.   latex = NULL;
  2339.   strip = NULL;
  2340.   tabel = NULL;
  2341.   wpd = NULL;
  2342.  
  2343.   Init_commando();
  2344.  
  2345.   /* ClrScr(); */
  2346.   putchar(0xc);
  2347.   printf("\n     Conversion program : From Wordperfect 5.1 to LaTeX  (wp2latex)\n\n");
  2348.   printf("  (c) TUE-Eindhoven ---- Written by R.C.Houtepen ---- Date : 24 Jan 1990\n");
  2349.   printf("      Translated into C by G. Geers ---- Date : 2 Aug 1990\n");
  2350.  
  2351.   Filenames();
  2352.  
  2353.   if (wpd != NULL)
  2354.     wpd = freopen(wpd_NAME, "r+b", wpd);
  2355.   else
  2356.     wpd = fopen(wpd_NAME, "r+b");
  2357.   if (wpd == NULL)
  2358.     _EscIO(FileNotFound);
  2359.   Wpd_check();
  2360.  
  2361.   if (strip != NULL)
  2362.     strip = freopen(strip_NAME, "w", strip);
  2363.   else
  2364.     strip = fopen(strip_NAME, "w");
  2365.   if (strip == NULL)
  2366.     _EscIO(FileNotFound);
  2367.   if (tabel != NULL)
  2368.     tabel = freopen(tabel_NAME, "w+b", tabel);
  2369.   else
  2370.     tabel = fopen(tabel_NAME, "w+b");
  2371.   if (tabel == NULL)
  2372.     _EscIO(FileNotFound);
  2373.  
  2374.   printf("Converting ...\n\n");
  2375.  
  2376.   Convert_first_strike();
  2377.  
  2378.   if (wpd != NULL)
  2379.     fclose(wpd);
  2380.   wpd = NULL;
  2381.   if (strip != NULL)
  2382.     fclose(strip);
  2383.   strip = NULL;
  2384.   if (tabel != NULL)
  2385.     fclose(tabel);
  2386.   tabel = NULL;
  2387.  
  2388.   if (strip != NULL)
  2389.     strip = freopen(strip_NAME, "r", strip);
  2390.   else
  2391.     strip = fopen(strip_NAME, "r");
  2392.   if (strip == NULL)
  2393.     _EscIO(FileNotFound);
  2394.   if (tabel != NULL)
  2395.     tabel = freopen(tabel_NAME, "r+b", tabel);
  2396.   else
  2397.     tabel = fopen(tabel_NAME, "r+b");
  2398.   if (tabel == NULL)
  2399.     _EscIO(FileNotFound);
  2400.   if (latex != NULL)
  2401.     latex = freopen(latex_NAME, "w", latex);
  2402.   else
  2403.     latex = fopen(latex_NAME, "w");
  2404.   if (latex == NULL)
  2405.     _EscIO(FileNotFound);
  2406.  
  2407.   Convert_second_strike();
  2408.  
  2409.   if (wpd != NULL)
  2410.     fclose(wpd);
  2411.   if (latex != NULL)
  2412.     fclose(latex);
  2413.  
  2414. /*
  2415. ** Delete auxillary files
  2416. */
  2417. #ifndef DEBUG
  2418.   if (strip != NULL)
  2419.     unlink(strip_fn);
  2420.   if (tabel != NULL)
  2421.     unlink(tabel_fn);
  2422. #endif
  2423.  
  2424.   printf("\nConversion completed.\n");
  2425.   exit(0);
  2426. }
  2427. /* End. */
  2428.  
  2429. /*
  2430. ** Extras - hand coded 
  2431. */
  2432.  
  2433. Static Void
  2434. RunError(errcode)
  2435. int errcode;
  2436. {
  2437.     switch (errcode) {
  2438.         case 0x201:
  2439.             fprintf(stderr, "Not a WordPerfect 5.1 document !\n");
  2440.             break;
  2441.         case 0x200:
  2442.             fprintf(stderr, "No filename entered !\n");
  2443.             break;
  2444.         case 0x100:
  2445.             fprintf(stderr, "Program error.\n");
  2446.             break;
  2447.         case 0x03:
  2448.             fprintf(stderr, "Path not found.\n");
  2449.             break;
  2450.         case 0x02:
  2451.             fprintf(stderr, "File not found.\n");
  2452.             break;
  2453.     }
  2454.     exit(errcode);
  2455. }
  2456.